import './js/libs/weapp-adapter'
import './js/libs/symbol'
var qcloud = require('./js/libs/wafer2-client-sdk/index')

var config = require('./config')
var util = require('./js/utils/util.js')
var runtime = require('./js/index.js')



const CANVAS_WIDTH = canvas.width
const CANVAS_HEIGHT = canvas.height

/******************************************************************
 * 登录
 */
qcloud.setLoginUrl(config.service.loginUrl)

window._globalData = {
  tunnelStatus: 'unconnected', //只建立一个长连接websocket
  isLogin: false,
  userInfo: {}, //登录账号信息
  score:'0',
  usetime:'0',
  realTimeRank: [] // 榜单
};

runtime.handleLogin()



/******************************************************************
 * 打开websocket信道长连接
 */
// runtime.openTunnel()

// //监听小游戏隐藏到后台事件。锁屏、按 HOME 键退到桌面、显示在聊天顶部等操作会触发此事件
// wx.onHide(() => { console.log("主动关闭信道"); runtime.closeTunnel() } )



/************************************************************************
 * 绘制启动页
 */
var context = canvas.getContext('2d')

context.fillStyle = "#44a7e6"
context.fillRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT)


var image = new Image()
image.onload = function () {
  context.drawImage(image, (canvas.width-100)/2, (canvas.height-370)/2,100,100)
}
image.src = 'images/round.png'

context.fillStyle = "#c4d73b"
context.font = "20px Edwardian Script ITC"
context.fillText('Develop by Malcolm', (canvas.width - 170) / 2, (canvas.height-140))




